A computer program is a series of instructions given to a computing device to make the device perform specific operations. Because a modern computer program can be very complex, it is often useful to write the program at a high level of abstraction. Object-oriented programming techniques facilitate such high level abstraction by allowing a programmer to conceptualize segments of the program as distinct objects. For instance, an object might contain a collection of attributes and methods. In addition, the object has one or more interfaces. Each interface contains information about how client program segments can interact with the object associated with the interfaces. Client program segments can only change the attributes contained within the object through methods defined by one of interfaces associated with the object. An actual implementation of an object is a class. Viewed from the opposite direction, an object, as actually used in computer software, is an instance of a class.
A child class is a class that contains the functionality of a parent class. In general, the child class has all of the interfaces, methods, and attributes of the parent class. In other words, the child class inherits the interfaces, methods, and attributes of the parent class. However, the child class may contain interfaces, methods, and attributes in addition to those inherited from the parent class. In this way, a child class may be understood as an adapter for the parent class. As described by Gamma, Helm, Johnson, Vlissides, DESIGN PATTERNS, 139, Addison-Wesley (1995), an adapter converts the interface of a class into another interface that clients expect. Furthermore, the child class may implement the methods of the parent object in alternative ways. In the context of the Java™ and C++ programming languages, child classes are referred to as subclasses and parent classes are known as super classes. Child objects and parent objects are instances of child classes and parent classes.
All classes, parent and child, must be defined before the code embodying the classes is compiled. After compilation the class definitions are immutable. Therefore, a client cannot generally define a new class or create instances of such a class at run-time. However, in certain situations, fixed object definitions are not always desirable. For example, it is sometimes necessary at run-time to define a child object that has a new interface, adds a new attribute, or overrides an existing method of an existing object. Gamma, supra, 175, refers to the process of adding responsibilities to an object at run-time when the object is utilized by a client as decoration or wrapping.
Current methods of creating objects that fit with the parent/child class scheme at run-time are often cumbersome and inelegant. Such methods typically force the client to view the objects outside the object-oriented paradigm. For example, a dynamic proxy object technique promulgated by Sun Microsystems Inc. of Santa Clara, Calif. allows the creation of client-defined objects at run-time. However, this technique does not represent the client-defined objects in terms of a parent object/child class relationship. This means that the client software may have to treat the client-defined object differently than an object whose interfaces and method implementations were specified at compile-time. Treating objects differently based on time of creation disrupts the object-oriented programming paradigm, disturbs the logical flow of the programming language code, and may complicate debugging. In addition, conventional dynamic proxy object techniques are often central processing unit (CPU) intensive.